package is.progetto2.gui;

import is.progetto2.activity.ResultSchedule;
import javax.swing.table.AbstractTableModel;

public class ScheduleTableModel extends AbstractTableModel {

	private static final long serialVersionUID = 1L;
	private ResultSchedule resultSchedule;
	
	public ScheduleTableModel(ResultSchedule rs){
		this.resultSchedule=rs;
	}
	
	@Override
	public String getColumnName(int arg0) {
		if(arg0==0){
			return "Job";
		}
		return new Integer(arg0).toString();
	}

	@Override
	public int getColumnCount() {
		return resultSchedule.getDuration()+1;
	}

	@Override
	public int getRowCount() {
		return resultSchedule.getJobSize();
	}

	@Override
	public Object getValueAt(int arg0, int arg1) {
		if(arg1==0){
			return new Integer(arg0+1).toString();
		}
		if(resultSchedule.isJobTime(resultSchedule.getJob(arg0), arg1)){
			return "*";
		}
		return "";
	}

}
